package org.gao.test.transaction.web.sample;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class ConnectionFactory {

	private static Context ctx;
	public static Connection getConn() {
		
		Connection conn = null;
		try {
			if(ctx == null) {
				ctx = new InitialContext();
			}
			DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/qiyexuexiDS");
			
			conn = ds.getConnection();
			
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return conn;
	}
}
